<template>
  <div class="app-container">
    <el-card header="基础信息" style="width: 100%">
      <div slot="header" class="clearfix">
        <span>基础信息</span>
        <el-button type="primary" @click="handleSearch" size="mini" style="float: right; margin: 0px 10px">查询</el-button>
      </div>
      <el-form class="demo-form-inline" :model="form" ref="formMain" label-width="135px" style="width: 100%">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="机型" prop="itmMstrJzdm">
              <HdSearchInput
                v-model="form.itmMstrJzdm"
                keyName="itmMstrJzdm"
                modulePath="rdmodule/researchData"
                @change="
                  (value) => {
                    handleChangeJzdm(value)
                  }
                "
                placeholder="请选择机种代码"></HdSearchInput>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-tabs v-model="activeName">
        <el-tab-pane label="明细数据" name="first">
          <el-table :data="tableData" border style="width: 100%; min-height: 560px">
            <el-table-column prop="itmMstrJzdm" label="机种代码"></el-table-column>
            <el-table-column prop="sampleDeliveryRate" label="送样及时率"></el-table-column>
            <el-table-column prop="dataIntegrityRate" label="资料完整率"></el-table-column>
          </el-table>
          <el-pagination
            style="float: right; margin-top: 20px"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="form.pageNum"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"></el-pagination>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
//研发KPi报表
import RdmoduleService from '@/api/rdmodule/rdmodule'
export default {
  name: 'KpiReport',
  data() {
    return {
      modulePermi: 'rdmodule:KpiReport',
      form: {
        pageNum: 1,
        pageSize: 10,
        itmMstrJzdm: '',
      },
      total: 0,

      activeName: 'first',
      tableData: [],
      tableDataHeight: 'calc(100% - 60px)',
      options: [
        { prop: 'itmCustwldm', label: '客户编码' },
        { prop: 'bomWldm', label: '物料代码', width: '120px' },
        { prop: 'itmPmgg', label: '产品名称' },
      ],
    }
  },
  created() {
    this.handleSearch()
  },
  methods: {
    handleSearch() {
      RdmoduleService.getKpiReport(this.form).then((res) => {
        if (res.code == 200) {
          this.tableData = res.rows
          this.total = res.total
          this.$message.success('查询成功')
        }
      })
    },
    handleChangeJzdm(val) {
      this.form.itmMstrJzdm = val.itmMstrJzdm
    },
    handleSizeChange(val) {
      this.form.pageSize = val
      this.handleSearch()
    },
    handleCurrentChange(val) {
      this.form.pageNum = val
      this.handleSearch()
    },
  },
}
</script>

<style lang="scss" scoped></style>
